<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>文档类型列表</title>
	<hdjs />
	<js file='__PUBLIC__/js/mod.base.js' />
	<css file='__PUBLIC__/Css/mod.base.css' />
</head>
<body>

	


		

		<form action="{:U('Attr/update')}" method="post" id='list'>
			<div class="hd-menu-list">
				<ul>
					<li>
						<a  href="{:U('Type/index')}" >
							类型列表
						</a>
					</li>
					<li class="active">
						<a href="javascript:;" >
							属性列表
						</a>
					</li>
					<li>
						<a href="{:U('Attr/add',array('typeid'=>$_GET['typeid']))}">
							添加属性
						</a>
					</li>
					<li>
						<a href="{:U('Attr/update_cache',array('typeid'=>$_GET['typeid']))}">
							更新缓存
						</a>
					</li>
				</ul>
			</div>
			<div class="hd-title-header">
            {$type}属性列表
        	</div>
			<table class="hd-table hd-table-list hd-form">
				<thead>
					<tr>
						<td class="hd-w30">
						<input type="checkbox" class="select_all"/>
						</td>
						<td class="hd-w30">ATTR_ID</td>
						<td class="hd-w50">排序</td>
						<td >属性名称</td>
						<td class="hd-w50">类型</td>
						
						<td class="hd-w180">操作</td>
					</tr>
				</thead>
				<if condition="$data">
				<foreach name='data' item='v'>
				<tr>
					<td><input type="checkbox" name="attr_id[{$v.attr_id}]" value="{$v.attr_id}"/></td>
					<td>{$v.attr_id}</td>
					<td><input type="text" class="hd-w30" value="{$v.sort}" name="list_order[{$v.attr_id}]"/></td>
					<td>{$v.attr_name}</td>
					<td>{$v.type}</td>
					<td>
					
					
						<a href="{:U('Attr/edit',array('attr_id'=>$v['attr_id'],'typeid'=>$v['type_typeid']))}">
							修改
						</a>
						<span class="line">|</span>
						<a href="javascript:var del='{:U('Attr/del',array('attr_id'=>$v['attr_id'],'typeid'=>$v['type_typeid']))}';hd_modal_confirm('确认删除吗？',del)">
							删除
						</a>
					</td>
				</tr>
				</foreach>
				
				<else />
				<tr><td colspan="9">没有找到符合的记录</td></tr>
				</if>
					
				</table>
			
			<input type="hidden" value='{$Think.get.typeid}'  name="typeid" />
		</form>

	<div class="hd-position-bottom">
		<input type="button" class="hd-btn hd-btn-xm" onclick="select_all(1)" value='全选'/>
		<input type="button" class="hd-btn hd-btn-xm" onclick="select_all(0)" value='反选'/>
		<input type="button" class="hd-btn hd-btn-xm" onclick="update(1)" value="更改排序"  />
		<input class="hd-btn hd-btn-xm" type="button" value="删除" onclick="update(4)" >
		
	</div>
<script>
//更新
function update(type) {
    //栏目检测
    var html;
    switch(parseInt(type))
	{
		case 1:
		type='排序';
		html='<input type="hidden" name="order" />';
		break;
		case 4:type='删除';
		html='<input type="hidden" name="del_check" />';
		break;
	}
    if ($("input[type='checkbox']:checked").length == 0) 
    {
        alert('没有信息用于'+type);
        return false;
    }
    $('#list').append(html);
  	$('#list').submit();
}
//点击input表单实现 全选或反选
$(function () {
    //全选
    $("input.select_all").click(function () {
        $("[type='checkbox']").attr("checked",$(this).attr('checked')=='checked');
    })
})
//全选复选框
function select_all(state){
	if(state==1){
		$("[type='checkbox']").attr("checked",state);
	}else{
		$("[type='checkbox']").attr("checked",function(){return !$(this).attr('checked')});
	}
}

</script>

</body>
</html>